package com.sunwayworld.basemodule.common.asynctask.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.sunwayworld.framework.at.annotation.AuditTrailType;
import com.sunwayworld.framework.at.annotation.AuditTrailEntry;
import com.sunwayworld.framework.spring.annotation.GikamBean;

import com.sunwayworld.basemodule.common.asynctask.dao.LimsAsynctaskScheduleDao;
import com.sunwayworld.basemodule.common.asynctask.bean.LimsAsynctaskScheduleBean;
import com.sunwayworld.basemodule.common.asynctask.service.LimsAsynctaskScheduleService;
import com.sunwayworld.framework.context.ApplicationContextHelper;
import com.sunwayworld.framework.restful.data.RestJsonWrapperBean;

@Repository
@GikamBean
public class LimsAsynctaskScheduleServiceImpl implements LimsAsynctaskScheduleService {

    @Autowired
    private LimsAsynctaskScheduleDao limsAsynctaskScheduleDao;

    @Override
    @SuppressWarnings("unchecked")
    public LimsAsynctaskScheduleDao getDao() {
        return limsAsynctaskScheduleDao;
    }

    @Override
    @Transactional
    @AuditTrailEntry(AuditTrailType.INSERT)
    public Long insert(RestJsonWrapperBean jsonWrapper) {
        LimsAsynctaskScheduleBean limsAsynctaskSchedule = jsonWrapper.parseUnique(LimsAsynctaskScheduleBean.class);
        limsAsynctaskSchedule.setId(ApplicationContextHelper.getNextIdentity());
        getDao().insert(limsAsynctaskSchedule);
        return limsAsynctaskSchedule.getId();
    }

}
